﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 第二次作业.entity.impl
{
    // 定义长方形类
    public class Rectangle : Shape
    {
        private double length;
        private double width;

        public Rectangle(double length, double width)
        {
            this.length = length;
            this.width = width;
        }

        public double Length
        {
            get { return length; }
            set { length = value; }
        }

        public double Width
        {
            get { return width; }
            set { width = value; }
        }

        // 实现接口IShape的Area方法
        public override double Area()
        {
            return length * width;
        }

        // 实现接口IShape的IsLegal方法
        public override bool IsLegal()
        {
            return length > 0 && width > 0;
        }
    }

    public class Square : Rectangle
    {
        public Square(double side) : base(side, side) { }
    }
}
